package com.ztesoft.web.datarecovery.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.framework.log.ZTEsoftLogManager;
import com.ztesoft.web.datarecovery.service.IDmDataRecoveryService;
import com.ztesoft.web.taskgenerator.db.po.DmTaskPO;

/**
 * <Description>dmdatarecovery管理 <br>
 * 
 * @author linjie <br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2016年4月20日 <br>
 * @since V1.0<br>
 * @see com.ztesoft.web.datarecovery.controller <br>
 */

@Controller
@RequestMapping("/datarecovery/dmdatarecovery")
public class DmDataRecoveryController {

	private static final ZTEsoftLogManager LOGGER = ZTEsoftLogManager.getLogger(DmDataRecoveryController.class);

	@Autowired
	private IDmDataRecoveryService dmDataRecoveryService;

	/**
	 * 数据恢复界面
	 * 
	 * @param record
	 * @param resultPage
	 * @return
	 * @throws BaseAppException
	 */
	@RequestMapping("queryRecordByPageForDataRecovery")
	@ResponseBody
	public Page<DmTaskPO> queryRecordByPageForDataRecovery(DmTaskPO record, Page<DmTaskPO> resultPage)
			throws BaseAppException {
		resultPage = dmDataRecoveryService.queryRecordByPageForDataRecovery(record, resultPage);
		return resultPage;
	}

	/**
	 * 数据恢复
	 * 
	 * @param record
	 * @param resultPage
	 * @return
	 * @throws BaseAppException
	 */
	@RequestMapping("dataRecovery")
	@ResponseBody
	public Map<String, Integer> dataRecovery(@RequestParam("dmTaskIds") String dmTaskIds) {
		return dmDataRecoveryService.dataRecovery(dmTaskIds);
	}

	/**
	 * 数据恢复完成
	 * 
	 * @param record
	 * @param resultPage
	 * @return
	 * @throws BaseAppException
	 */
	@RequestMapping("dataRecoveryOK")
	@ResponseBody
	public int dataRecoveryOK(@RequestParam("dmTaskIds") String dmTaskIds) {
		return dmDataRecoveryService.dataRecoveryOK(dmTaskIds);
	}
}
